//
//  XSVistorViewController.swift
//  WeiDo
//
//  Created by XISHAN on 16/3/3.
//  Copyright © 2016年 XISHAN. All rights reserved.
//

import UIKit

class XSVistorViewController: UITableViewController {
    
    //判断用户是否登录
    var isLogin :Bool = XSUserAccountViewModel.sharedAccountViewModel.isLogin
    
    
    
    override func loadView() {
        
        if isLogin{
            super.loadView()
        }else{
            setupVistorView()
        }
    }
    
    //访客模式View
    func setupVistorView(){
        
        view = vistorView

        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "login")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "login")
    }
    
    lazy var vistorView:XSVistorView = {
        
        let v = XSVistorView()
     
        v.delegate = self
        return v
    }()
    
    func login(){
        print("登录")
        
        let oaVc = XSOAthViewcontroller()
        
        presentViewController(XSNavigationViewController(rootViewController: oaVc), animated: true, completion: nil)
      
    }

}
extension XSVistorViewController:XSVistorViewDelegate {
    
    func vistorView(vistorView: XSVistorView, loginBtnDidClick: UIButton) {
        login()
    }
}
